package com.example.roadeyeserver.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.roadeyeserver.annotation.DS;
import com.example.roadeyeserver.entity.GpsNbbj;
import com.example.roadeyeserver.entity.vo.GpsNbbjVO;
import com.example.roadeyeserver.mapper.GpsNbbjMapper;
import com.example.roadeyeserver.result.Result;
import com.example.roadeyeserver.service.GpsNbbjService;
import com.example.roadeyeserver.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class GpsNbbjServiceImpl extends ServiceImpl<GpsNbbjMapper, GpsNbbj> implements GpsNbbjService {

    @Resource
    private GpsNbbjMapper gpsNbbjMapper;

    @Override
    @DS("db2")
    public Result<List<GpsNbbjVO>> getLatestGpsCars() {
        // 查询数据,如果车牌号重复则只取一条
        List<GpsNbbjVO> result = gpsNbbjMapper.getLatestGpsCars();
        log.info("查询到:{}条结果", result.size());
        return ResultUtil.success(result);
    }
}
